<template>
  <div>
    <Chart :cdata="cdata" />
  </div>
</template>

<script>
import Chart from './chart.vue'
export default {
  data () {
    return {
      cdata: {
        category: [
          "车辆道闸",
          "人脸相机",
          "视频监控",
          "人脸门禁",
          "智能路灯",
          "智能消防栓"
        ],
        lineData: [//离线
          0,
          0,
          0,
          1,
          1,
          1
        ],
        barData: [//在线
          1,
          1,
          1,
          0,
          0,
          0
        ],
        rateData: []
      }
    };
  },
  components: {
    Chart,
  },
  mounted () {
    this.setData();
  },
  methods: {
    // 根据自己的业务情况修改
    setData () {
      for (let i = 0; i < this.cdata.barData.length; i++) {
        let rate = this.cdata.barData[i] / (this.cdata.lineData[i]+this.cdata.barData[i]);
        this.cdata.rateData.push(rate.toFixed(2));
      }
    },
  }
};
</script>

<style lang="scss" scoped>
</style>
